Skip to content

[Feat] [Py] Refactor Python binding#275

Closed
haochengxia wants to merge 4 commits intodevelopfrom
hxia/py_refactor
Closed

[Feat] [Py] Refactor Python binding#275
haochengxia wants to merge 4 commits intodevelopfrom
hxia/py_refactor

Conversation

@haochengxia
Copy link
Copy Markdown
Collaborator

@haochengxia haochengxia commented Jul 21, 2025

In order to substantially improve the maintainability, we make a huge refactor inspired by the project taichi,

  • Bind analyzer
  • Simplify the registration of different replacement algorithms

TODO:

  • Connect S3
  • Add tests
  • Update documentations
  • Only preserve reader_protocol and mark it should be removed once we have streaming synthetic reader at c++ side

@haochengxia haochengxia requested a review from Copilot July 21, 2025 03:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the Python bindings for libCacheSim to simplify the registration of different replacement algorithms and add analyzer bindings. The refactoring replaces the monolithic C++ binding file with a modular approach organized across multiple files, each handling specific functionality areas.

  • Splits the large pylibcachesim.cpp into specialized modules for better maintainability
  • Introduces new Python wrapper classes that provide a unified interface for cache algorithms
  • Adds analyzer bindings to enable trace analysis functionality

Reviewed Changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/install_python_dev.sh Updates pip command to use python -m pip for better compatibility
libCacheSim-python/src/pylibcachesim.cpp Removes the entire monolithic C++ binding implementation
libCacheSim-python/src/export_*.cpp New modular C++ export files for cache, reader, analyzer, and misc functionality
libCacheSim-python/libcachesim/*.py New Python wrapper modules providing clean interfaces
libCacheSim-python/tests/* Removes existing test files (likely to be replaced)
Comments suppressed due to low confidence (2)

libCacheSim-python/libcachesim/cache.py:354

  • [nitpick] The function name 'nop_method' is unclear. Consider renaming to 'default_hook' or 'no_op_hook' to better indicate its purpose as a default hook function.
def nop_method(*args, **kwargs):

libCacheSim-python/src/export.cpp:17

  • [nitpick] The module name 'libcachesim_python' contains an underscore which may not follow Python naming conventions. Consider using 'libcachesim' or 'libcachesim_py' for consistency.
PYBIND11_MODULE(libcachesim_python, m) {

Comment thread libCacheSim-python/src/export_cache.cpp Outdated
Comment thread libCacheSim-python/src/export_cache.cpp Outdated
Comment thread libCacheSim-python/src/export_reader.cpp Outdated
Comment thread libCacheSim-python/libcachesim/synthetic_reader.py Outdated
@haochengxia haochengxia deleted the hxia/py_refactor branch July 28, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants